package md.lanjing.com.module_deal_center.contact;

import android.content.Context;

import com.lxh.baselibray.mvp.BasePresent;
import com.lxh.baselibray.mvp.IBaseView;
import com.lxh.baselibray.net.NetCallBack;
import com.lxh.baselibray.net.ServiceGenerator;
import com.lxh.baselibray.util.Md5Utils;
import com.lxh.baselibray.util.SPUtils;
import com.lxh.baselibray.util.ToastUtils;


import md.lanjing.com.module_deal_center.R;
import md.lanjing.com.module_deal_center.api.DealApiService;
import md.lanjing.com.module_deal_center.bean.BuyBillDetailRequest;
import md.lanjing.com.module_deal_center.bean.BuyBillDetailResponce;
import com.lxh.baselibray.constant.Constant;
import retrofit2.Call;
import retrofit2.Response;

public class BuyDetailContact {
    public static class  BuyDetailPresent extends BasePresent<IBuyDetailView> {
        public void lockBill(final Context context, String dealPwd, double tokenNum, String billId){
            DealApiService service= ServiceGenerator.createService(DealApiService.class);
            int userId= SPUtils.getInt(Constant.USER_ID,-1,context);
            BuyBillDetailRequest request=new BuyBillDetailRequest(Md5Utils.stringToMD5(dealPwd),userId,tokenNum,billId);
            service.lockBill(request).enqueue(new NetCallBack<BuyBillDetailResponce>() {
                @Override
                public void onSuccess(Call<BuyBillDetailResponce> call, Response<BuyBillDetailResponce> response) {
                    if (getView()!=null){
                        getView().getLockBillData(response);
                    }
                }

                @Override
                public void onFailed() {
                    ToastUtils.showLongToast(context,context.getString(R.string.request_failed));
                }
            });
        }
    }
    public interface IBuyDetailView extends IBaseView {
        void getLockBillData(Response<BuyBillDetailResponce> response);
    }
}
